package com.skt.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skt.common.annotation.Log;
import com.skt.common.core.controller.BaseController;
import com.skt.common.core.domain.AjaxResult;
import com.skt.common.enums.BusinessType;
import com.skt.manage.domain.DoctorTreatments;
import com.skt.manage.service.IDoctorTreatmentsService;
import com.skt.common.utils.poi.ExcelUtil;
import com.skt.common.core.page.TableDataInfo;

/**
 * 医生诊疗管理Controller
 * 
 * @author ffbaby
 * @date 2025-02-22
 */
@RestController
@RequestMapping("/manage/treatments")
public class DoctorTreatmentsController extends BaseController
{
    @Autowired
    private IDoctorTreatmentsService doctorTreatmentsService;

    /**
     * 查询医生诊疗管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:treatments:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorTreatments doctorTreatments)
    {
        startPage();
        List<DoctorTreatments> list = doctorTreatmentsService.selectDoctorTreatmentsList(doctorTreatments);
        return getDataTable(list);
    }

    /**
     * 导出医生诊疗管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:treatments:export')")
    @Log(title = "医生诊疗管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoctorTreatments doctorTreatments)
    {
        List<DoctorTreatments> list = doctorTreatmentsService.selectDoctorTreatmentsList(doctorTreatments);
        ExcelUtil<DoctorTreatments> util = new ExcelUtil<DoctorTreatments>(DoctorTreatments.class);
        util.exportExcel(response, list, "医生诊疗管理数据");
    }

    /**
     * 获取医生诊疗管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:treatments:query')")
    @GetMapping(value = "/{treatmentId}")
    public AjaxResult getInfo(@PathVariable("treatmentId") Long treatmentId)
    {
        return success(doctorTreatmentsService.selectDoctorTreatmentsByTreatmentId(treatmentId));
    }

    /**
     * 新增医生诊疗管理
     */
    @PreAuthorize("@ss.hasPermi('manage:treatments:add')")
    @Log(title = "医生诊疗管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorTreatments doctorTreatments)
    {
        return toAjax(doctorTreatmentsService.insertDoctorTreatments(doctorTreatments));
    }

    /**
     * 修改医生诊疗管理
     */
    @PreAuthorize("@ss.hasPermi('manage:treatments:edit')")
    @Log(title = "医生诊疗管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorTreatments doctorTreatments)
    {
        return toAjax(doctorTreatmentsService.updateDoctorTreatments(doctorTreatments));
    }

    /**
     * 删除医生诊疗管理
     */
    @PreAuthorize("@ss.hasPermi('manage:treatments:remove')")
    @Log(title = "医生诊疗管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{treatmentIds}")
    public AjaxResult remove(@PathVariable Long[] treatmentIds)
    {
        return toAjax(doctorTreatmentsService.deleteDoctorTreatmentsByTreatmentIds(treatmentIds));
    }
}
